<?php
namespace app\admin\controller;
use think\Session;
use think\Request;
use think\Controller;
class Index extends Common
{
    public function index()
    {
        return view();
    }
    public function order_detail()
    {
        return view();
    }
    public function revise_password(){
      
        return view();
    }
    public function code_pwd(){
        $user=input('get.user');
        $email=input('get.email');
        $oldpwd=md5(input('get.oldpwd'));
        $id=db('admin')->where(['user'=>$user,'email'=>$email,'pwd'=>$oldpwd])->select();
        if($id){
            return true;
        }
    }
    public function edit_pwd(){
        $user=input('post.user');
        $post['pwd']=md5(input('post.pwd'));
        $res=db('admin')->where('user',$user)->update($post);
        if($res){
            Session::delete('user');
            Session::delete('id');
            echo "<script>
            parent.location.href='".url('login/login')."';
            </script>";
        }else{
            $this->error('修改失败');
        }
    }
    public function order_list()
    {
        return view();
    }
    public function bar()
    {
        return view();
    }
    public function main()
    {
        return view();
    }
    public function menu()
    {
        $request=Request::instance();
        $module=$request->module();
        $controller=$request->controller();
        $action=$request->action();  
        $current_href=strtolower($module.'/'.$controller.'/'.$action);
        $caidan=caidan(session('permission_id'));
        $this->assign('caidan',$caidan);
        $this->assign('current_href',$current_href);
        return view();
    }
    public function top()
    {
        return view();
    }
    public function text(){
        return view();
    }
    public function admin_list(){
        return view();
    }
    public function file(){
        $files = request()->file('image');
        foreach($files as $file){
            $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
            if($info){
                $image= $info->getFilename(); 
                dump($image);
            }else{
                echo $file->getError();
            }    
        }
    }
}
